<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.util.Vector,com.ejoysoft.wlanyz.business.Sitetest,com.ejoysoft.common.Constants,com.ejoysoft.wlanyz.system.SysUserUnit,com.ejoysoft.common.exception.NoRightException" %>
<%@ include file="../include/jsp/head.jsp"%>
<%@page import="sun.reflect.generics.tree.IntSignature"%>
<%@page import="com.ejoysoft.common.Format"%>
<% 
    //初始化
   Sitetest  user0=null;
   Sitetest  obj=new Sitetest (globa);
    //查询条件
     String  strCity = ParamUtil.getString(request,"strCity","");
     String  strComm = ParamUtil.getString(request,"strComm","");
    String  strStartTime = ParamUtil.getString(request,"strStartTime","");
    String  strEndTime = ParamUtil.getString(request,"strEndTime","");
    if(strStartTime.equals(""))strStartTime = "1000-01-01";
    if(strEndTime.equals(""))strEndTime = "9999-12-30"; 
	//System.out.println("查询条件："+strStartTime+"时间"+strEndTime);

	//查询条件
	String tWhere = " and wlan_test_result.dtcreatdate between to_date('" + strStartTime + "','yyyy-MM-dd hh24.mi.ss') and to_date('" + strEndTime + "','yyyy-MM-dd hh24.mi.ss')" ;
	
	if(strCity!=""){
		tWhere += " and wlan_resc_hotpot.strcity like '%"+strCity+"%'";
	}
	if(strComm!=""){
		tWhere += " and wlan_resc_comunity.strsitename like '%"+strComm+"%'";
	}
	
	tWhere += "and wlan_test_result.strnettype='TD'";
	
	
	String checked1 =  ParamUtil.getString(request,"checkedFlag","all"); 
	if(checked1.equals("checked")){
	  tWhere += " and checkedLocation is not null and checkedLocation <>' ' ";
	}
	else if(checked1.equals("unchecked")){
	  tWhere += " and checkedLocation is null or checkedLocation =' '";
	}
	 tWhere += "";

	//记录总数
	int intAllCount=obj.getCount(tWhere);	
	int intCurPage=globa.getIntCurPage();

	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集
	Vector<Sitetest > vctObj=obj.list(tWhere,intStartNum,intPageSize);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	System.out.println("输出哥哥哥哥哥哥："+intVct);
	String exportContent = ParamUtil.getString(request,"exportContent","");
		if(exportContent.equals("allPage"))
		{
			vctObj=obj.list(tWhere,0,0);
		}
   	   	StringBuffer sb = new StringBuffer("<html><body><table  border=1>");
	    sb.append("<tr><td>地市</td><td>区县</td><td>小区</td><td>LAC</td><td>CI</td><td>测试时间</td><td>测试地址</td></tr>");
	    
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       sb.append("<tr><td>"+(vctObj.get(i).getStrcity()==null?" ":vctObj.get(i).getStrcity()));
		       sb.append("</td><td>");
		       sb.append((vctObj.get(i).getStrtown()==null?" ":vctObj.get(i).getStrtown()));
		       sb.append("</td><td>");
		       sb.append((vctObj.get(i).getStrsitename()==null?" ":vctObj.get(i).getStrsitename()));
		       sb.append("</td><td>");
		       sb.append((vctObj.get(i).getStrlac()==null?" ":vctObj.get(i).getStrlac()));
		       sb.append("</td><td>");
		       sb.append((vctObj.get(i).getStrci()==null?" ":vctObj.get(i).getStrci()));
		       sb.append("</td><td>");
		       sb.append((vctObj.get(i).getStrdttime()==null?" ":vctObj.get(i).getStrdttime()));
		       sb.append("</td><td>");
		       sb.append((vctObj.get(i).getStrtestaddr()==null?" ":vctObj.get(i).getStrtestaddr()));
		       sb.append("</td></tr>");
		    }
	    } 
	    sb.append("</table></body></html>"); 
	    String strFileName = "随机现场测试TD结果分析表.xls";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());
	    globa.closeCon();
	    
%>
<%@ include file="../include/jsp/footer.jsp"%>
